fix(context): make provider-dropping note truthful for declared windows - #5174
Open
SummerC0zyR0ck wants to merge 1 commit into
Open
fix(context): make provider-dropping note truthful for declared windows#5174SummerC0zyR0ck wants to merge 1 commit into
SummerC0zyR0ck wants to merge 1 commit into
Conversation
me2seeks
approved these changes
Sep 11, 2026
me2seeks
left a comment
Contributor
There was a problem hiding this comment.
PR 5174 Review
结论
APPROVE
context_provider_dropping 现在在事件里记录调用时刻的声明状态 contextWindowDeclared: midTurnState.capacity !== undefined(ai-sdk-turn.ts:1737),三处渲染(TUI pi-transcript.ts、Desktop materialize.ts、三语 copy)对 true/false/legacy 三分支处理,legacy 记录用中性措辞、不反查可变配置,与描述一致。
发现
无
不确定性(不发到 GitHub 的疑虑)
- "truthful" 的边界情形:声明存在但 mid-turn compaction 未启用(
historyCompact.midTurn.enabled !== true)时midTurnState === undefined,note 根本不会发出(ai-sdk-turn.ts:1712要求midTurnState),所以不存在"声明了却没走 compaction 却仍说 will compact first"的矛盾路径——声明+midTurn 开启时capacity由resolveDeclaredContextWindow注入(ai-sdk-compaction.ts:890),两者一致。论证成立。 - 该 note 每个 session 只发一次(
contextProviderDroppingReportedlatch),记录在 durable transcript 里的状态与"当时"一致,重放不重算——符合 PR "does not infer current settings from mutable configuration" 的设计。 pi-transcript.ts与materialize.ts两处各自 castdata并判断 boolean,未共享一个 reader;重复但低风险,未发出。
✅ 对抗性审查(第一性原理 + 奥卡姆剃刀 + 证据核对)通过:未发现真实的 P0–P3 问题。@me2seeks 请把关是否 merge。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5137
context_provider_droppingcould be emitted for requests with an already-declared context window, but its Desktop and TUI copy always told the user to declare one. This produced contradictory system notes whencontext_window_overrunsimultaneously acknowledged the existing declaration.The note now records the declaration state at call time, using
midTurnState.capacityas the Runtime authority. Rendering handles all three cases:The behavior is consistent across Runtime data, Desktop materialization, English, zh-CN, zh-TW, and TUI rendering.
Verification
The issue reproduction was confirmed on the current main branch: the existing declared-window Runtime fixtures passed while the zh-CN renderer still told the user to declare a context window. After the fix, the declaration state is recorded in the durable note and the rendered guidance is truthful for declared, undeclared, and legacy records.
Passed affected builds and regressions:
contextWindowDeclaredvalue.npm run format:checknpm run check:tui-copynpm run check:locale-hygieneThe commit-time ASF license-header and protocol-epoch checks also passed.
The full repository test suite and full repository lint/typecheck suite were not run.
AI use
Tool(s) and scope: OpenAI Codex investigated the defect and fixed, authored the implementation review, Runtime/UI/TUI regression tests.
Checklist
Does this PR entail a change in behavior?